<?php
/*
 * 系统配置
 */
namespace app\admin\controller;
use app\common\controller\AdminBase;
use app\common\model\System;

class Setting extends AdminBase
{
    protected function _initialize()
    {
        parent::_initialize();
    }
    //系统配置
    public function base()
    {
        if ($this->request->isPost()) {
            $param = $this->request->param();
            foreach ($param as $key => $v) {
                $result = System::where('code',$key)->update(['value' => $v]);
                if ($v != '') {
                    $result = 1;
                }
            }
            !$result && $this->error($this->errorMsg);
            insert_admin_log('修改了配置');
            $this->success('修改成功');
        }
        $setting = System::where(['status' => 1])->order('sort asc')->select()->toArray();
        $list = list_to_tree($setting);
        return View('index', ['list' => $list]);
    }


}
